<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  
  <title>Promise探析 | </title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
    <meta name="keywords" content="EricWang's Blog">
  
  <meta name="description" content="&amp;#x524D;&amp;#x8A00; &amp;#x2003;&amp;#x2003;&amp;#x4E0A;&amp;#x4E00;&amp;#x7BC7;&amp;#xFF0C;&amp;#x5173;&amp;#x4E8E;axios&amp;#x7684;&amp;#x4E8C;&amp;#x6B21;&amp;#x5C01;&amp;#x88C5;&amp;#xFF0C;&amp;#x6211;&amp;#x4EEC;&amp;#x5DF2;&amp;#x7ECF;&amp;#x63A2;&amp;#x8BA8;&amp;#x8FC7;&amp;#x4EC0;&amp;#">
<meta name="keywords" content="Promise,DOM,ES6">
<meta property="og:type" content="article">
<meta property="og:title" content="Promise探析">
<meta property="og:url" content="https://bigbigdreamer.github.io/8640.html">
<meta property="og:site_name">
<meta property="og:description" content="&amp;#x524D;&amp;#x8A00; &amp;#x2003;&amp;#x2003;&amp;#x4E0A;&amp;#x4E00;&amp;#x7BC7;&amp;#xFF0C;&amp;#x5173;&amp;#x4E8E;axios&amp;#x7684;&amp;#x4E8C;&amp;#x6B21;&amp;#x5C01;&amp;#x88C5;&amp;#xFF0C;&amp;#x6211;&amp;#x4EEC;&amp;#x5DF2;&amp;#x7ECF;&amp;#x63A2;&amp;#x8BA8;&amp;#x8FC7;&amp;#x4EC0;&amp;#">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2018-12-30T00:54:50.533Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Promise探析">
<meta name="twitter:description" content="&amp;#x524D;&amp;#x8A00; &amp;#x2003;&amp;#x2003;&amp;#x4E0A;&amp;#x4E00;&amp;#x7BC7;&amp;#xFF0C;&amp;#x5173;&amp;#x4E8E;axios&amp;#x7684;&amp;#x4E8C;&amp;#x6B21;&amp;#x5C01;&amp;#x88C5;&amp;#xFF0C;&amp;#x6211;&amp;#x4EEC;&amp;#x5DF2;&amp;#x7ECF;&amp;#x63A2;&amp;#x8BA8;&amp;#x8FC7;&amp;#x4EC0;&amp;#">
  
  
    <link rel="icon" href="favicon.ico">
  
  <link href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
  <link rel="stylesheet" href="/css/style.css">
  <script src="/js/pace.min.js"></script>
  

  
	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?490c72c80e7c5f485272ffc6d84c956b";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>

  

  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
      }
      else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
      }
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>
  <meta name="google-site-verification" content="2yIvO7JmvHMSNv3topeJQ8rrtv6HN-mKjYLR5sdxeaQ">
</head>
</html>
<body>
  <div id="container">
      <header id="header">
    <div id="banner"></div>
    <div id="header-outer">
        <div id="header-menu" class="header-menu-pos animated">
            <div class="header-menu-container">
                <a href="/" class="left">
                    <span class="site-title">BigDreamer</span>
                </a>
                <nav id="header-menu-nav" class="right">
                    
                    <a href="/">
                        <i class="fa fa-home"></i>
                        <span>Home</span>
                    </a>
                    
                    <a href="/archives">
                        <i class="fa fa-archive"></i>
                        <span>Archives</span>
                    </a>
                    
                    <a href="/about">
                        <i class="fa fa-user"></i>
                        <span>About</span>
                    </a>
                    
                </nav>
                <a class="mobile-header-menu-button">
                    <i class="fa fa-bars"></i>
                </a>
            </div>
        </div>
        <div id="header-row">
            <div id="logo">
                <a href="/">
                    <img src="/images/logo.jpg" alt="logo">
                </a>
            </div>
            <div class="header-info">
                <div id="header-title">
                    
                    <h2>
                        BigDreamer
                    </h2>
                    
                </div>
                <div id="header-description">
                    
                    <h3>
                        情不知所起，一往而深。
                    </h3>
                    
                </div>
            </div>
            <nav class="header-nav">
                <div class="social">
                    
                        <a title="EricWang" target="_blank" href="//ivu1314.club">
                            <i class="fa fa-home fa-2x"></i></a>
                    
                        <a title="Github" target="_blank" href="https://github.com/bigbigDreamer">
                            <i class="fa fa-github fa-2x"></i></a>
                    
                        <a title="QQ" target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=1826001146&site=qq&menu=yes">
                            <i class="fa fa-qq fa-2x"></i></a>
                    
                </div>
            </nav>
        </div>
    </div>
</header>
      <div class="outer">
        <section id="main" class="body-wrap"><article id="post-Promise" class="article article-type-post" itemscope="" itemprop="blogPost">
  <div class="article-inner">
    
      <header class="article-header">
        
  
    <h1 class="post-title" itemprop="name">
      Promise探析
    </h1>
    <div class="post-title-bar">
      <ul>
          
              <li>
                  <i class="fa fa-book"></i>
                  
                      <a href="/categories/ES6/">ES6</a>
                  
              </li>
          
        <li>
          <i class="fa fa-calendar"></i>  2018-11-06
        </li>
        <li>
          <i class="fa fa-eye"></i>
          <span id="busuanzi_value_page_pv"></span>
        </li>
      </ul>
    </div>
  

          
      </header>
    
    <div class="article-entry post-content" itemprop="articleBody">
      
            
            <h2 id="&#x524D;&#x8A00;"><a href="#&#x524D;&#x8A00;" class="headerlink" title="&#x524D;&#x8A00;"></a>&#x524D;&#x8A00;</h2><blockquote>
<p>&#x2003;&#x2003;&#x4E0A;&#x4E00;&#x7BC7;&#xFF0C;&#x5173;&#x4E8E;axios&#x7684;&#x4E8C;&#x6B21;&#x5C01;&#x88C5;&#xFF0C;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x63A2;&#x8BA8;&#x8FC7;&#x4EC0;&#x4E48;&#x662F;Promise&#xFF0C;&#x5B83;&#x53EF;&#x4EE5;&#x505A;&#x4EC0;&#x4E48;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x73B0;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x7EE7;&#x7EED;&#x6765;&#x901A;&#x8FC7;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;DOM&#x6848;&#x4F8B;&#x63A2;&#x6790;&#x3002;</p>
</blockquote>
<h2 id="&#x4F60;&#x8FD8;&#x5728;&#x8FD9;&#x6837;&#x5199;&#xFF1F;"><a href="#&#x4F60;&#x8FD8;&#x5728;&#x8FD9;&#x6837;&#x5199;&#xFF1F;" class="headerlink" title="&#x4F60;&#x8FD8;&#x5728;&#x8FD9;&#x6837;&#x5199;&#xFF1F;"></a>&#x4F60;&#x8FD8;&#x5728;&#x8FD9;&#x6837;&#x5199;&#xFF1F;</h2><h3 id="DOM&#x539F;&#x751F;&#x4E8B;&#x4EF6;"><a href="#DOM&#x539F;&#x751F;&#x4E8B;&#x4EF6;" class="headerlink" title="DOM&#x539F;&#x751F;&#x4E8B;&#x4EF6;"></a>DOM&#x539F;&#x751F;&#x4E8B;&#x4EF6;</h3><blockquote>
<p>&#x2003;&#x2003;&#x6839;&#x636E;MDN&#x4E0A;&#x9762;&#x7684;&#x76F8;&#x5173;&#x63A8;&#x8350;&#x6307;&#x5BFC;&#xFF0C;&#x6211;&#x4EEC;&#x5E94;&#x8BE5;&#x66F4;&#x591A;&#x5730;&#x53BB;&#x4F7F;&#x7528;addEventListener&#xFF0C;&#x800C;&#x975E;&#x90A3;&#x4E9B;&#x539F;&#x751F;&#x5B9A;&#x4E49;&#x7684;onclick&#x4E4B;&#x7C7B;&#x7684;&#x3002;</p>
</blockquote>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">//&#x6BD4;&#x5982;&#x6211;&#x4EEC;&#x5C1D;&#x8BD5;&#x53BB;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;&#x52A8;&#x753B;&#x6548;&#x679C;</span><br><span class="line">  window.onload = () =&gt; {</span><br><span class="line">    document.querySelector(<span class="string">&apos;.app1&apos;</span>)</span><br><span class="line">         .addEventListener(<span class="string">&apos;mouseenter&apos;</span>, (event) =&gt; {</span><br><span class="line">               const timer =  setInterval(()=&gt;{</span><br><span class="line">                    event.style.opacity += 0.1;</span><br><span class="line">                    <span class="keyword">if</span> (event.style.opacity === 1)</span><br><span class="line">                      clearInterval(timer);</span><br><span class="line">                 },1000/20)</span><br><span class="line">      });</span><br><span class="line">  }</span><br></pre></td></tr></tbody></table></figure>
<blockquote>
<p>&#x2003;&#x2003;&#x6211;&#x7684;&#x5929;&#x5450;&#xFF01;&#x4E00;&#x5C42;&#x3001;&#x4E24;&#x5C42;&#x2026;&#x2026;&#x603B;&#x5171;&#x4E09;&#x5C42;&#x56DE;&#x8C03;&#xFF0C;&#x8FD9;&#x5DF2;&#x7ECF;&#x8C03;&#x5165;&#x56DE;&#x8C03;&#x5730;&#x72F1;&#x4E86;&#xFF0C;&#x5982;&#x679C;&#x518D;&#x6DF1;&#x5165;&#x8BBE;&#x7F6E;&#x5176;&#x4ED6;&#x7684;&#x52A8;&#x753B;&#xFF0C;&#x90A3;&#x5C82;&#x4E0D;&#x662F;&#x66F4;&#x4E71;&#x4E86;&#xFF0C;&#x60F3;&#x60F3;&#x529E;&#x6CD5;&#x5427;&#x3002;</p>
</blockquote>
<h2 id="jQuery&#x5199;&#x6CD5;"><a href="#jQuery&#x5199;&#x6CD5;" class="headerlink" title="jQuery&#x5199;&#x6CD5;"></a>jQuery&#x5199;&#x6CD5;</h2><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">$(()=&gt;{</span><br><span class="line">  $(<span class="string">&apos;.app&apos;</span>).hover(<span class="keyword">function</span>(e)=&gt;{</span><br><span class="line">    const timer =  setInterval(()=&gt;{</span><br><span class="line">                      e.css({</span><br><span class="line">                          opacity:`++0.1`</span><br><span class="line">                      })</span><br><span class="line">                      <span class="keyword">if</span> (e.css(<span class="string">&apos;opacity&apos;</span>) === 1)</span><br><span class="line">                        clearInterval(timer);</span><br><span class="line">                   },1000/20)</span><br><span class="line">        });</span><br><span class="line">  });</span><br><span class="line">})</span><br></pre></td></tr></tbody></table></figure>
<blockquote>
<p>&#x2003;&#x2003;&#x4E00;&#x6837;&#x7684;&#x9178;&#x723D;&#x5BF9;&#x5427;&#xFF01;</p>
</blockquote>
<h2 id="&#x8FD9;&#x6837;&#x505A;&#x624D;&#x723D;"><a href="#&#x8FD9;&#x6837;&#x505A;&#x624D;&#x723D;" class="headerlink" title="&#x8FD9;&#x6837;&#x505A;&#x624D;&#x723D;"></a>&#x8FD9;&#x6837;&#x505A;&#x624D;&#x723D;</h2><h3 id="Demo"><a href="#Demo" class="headerlink" title="Demo"></a>Demo</h3><blockquote>
<p>JS&#x90E8;&#x5206;</p>
</blockquote>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">window.onload = () =&gt; {</span><br><span class="line">           <span class="built_in">return</span> new Promise((resolve) =&gt; {</span><br><span class="line">               document.querySelector(<span class="string">&apos;.app1&apos;</span>)</span><br><span class="line">                   .addEventListener(<span class="string">&apos;mouseenter&apos;</span>, () =&gt; {</span><br><span class="line">                       resolve(<span class="string">&apos;Test&apos;</span>);</span><br><span class="line">                   });</span><br><span class="line">           })</span><br><span class="line">               .<span class="keyword">then</span>((data) =&gt; {</span><br><span class="line">                   console.log(data);</span><br><span class="line">                   <span class="keyword">if</span> (data) {</span><br><span class="line">                       <span class="built_in">let</span> height =</span><br><span class="line">                           getComputedStyle(document.querySelector(<span class="string">&apos;.app2&apos;</span>))[<span class="string">&apos;top&apos;</span>];</span><br><span class="line">                       <span class="built_in">let</span> value = Number.parseInt(height);</span><br><span class="line">                       <span class="built_in">let</span> timer = setInterval(() =&gt; {</span><br><span class="line">                           value += 10;</span><br><span class="line">                           console.log(value);</span><br><span class="line">                           document.querySelector(<span class="string">&apos;.app2&apos;</span>)</span><br><span class="line">                               .style.top = `-<span class="variable">${value}</span>px`;</span><br><span class="line">                           <span class="keyword">if</span> (value === 200) {</span><br><span class="line">                               clearInterval(timer);</span><br><span class="line">                           }</span><br><span class="line">                       }, 1000 / 20);</span><br><span class="line">                   }</span><br><span class="line">                   <span class="built_in">return</span> <span class="literal">true</span>;</span><br><span class="line">               }, (err) =&gt; {</span><br><span class="line">                   console.log(err);</span><br><span class="line">               })</span><br><span class="line">               .<span class="keyword">then</span>((data) =&gt; {</span><br><span class="line">                   console.log(data);</span><br><span class="line">                   console.log(<span class="string">&apos;&#x5F00;&#x59CB;&#x6267;&#x884C;&#x663E;&#x793A;&apos;</span>);</span><br><span class="line">                   <span class="keyword">if</span> (data) {</span><br><span class="line">                       document.querySelector(<span class="string">&apos;.app2&apos;</span>)</span><br><span class="line">                           .style.display = <span class="string">&apos;block&apos;</span>;</span><br><span class="line">                       document.querySelector(<span class="string">&apos;.app2&apos;</span>)</span><br><span class="line">                           .style.opacity = 0.6;</span><br><span class="line">                   }</span><br><span class="line">               })</span><br><span class="line">       }</span><br></pre></td></tr></tbody></table></figure>
<blockquote>
<p>HTML&#x90E8;&#x5206;</p>
</blockquote>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">&lt;div class=<span class="string">&quot;box&quot;</span>&gt;</span><br><span class="line">    &lt;div class=<span class="string">&quot;app1&quot;</span>&gt;</span><br><span class="line">        &lt;img src=<span class="string">&quot;./logo.png&quot;</span> alt=<span class="string">&quot;logo&quot;</span>&gt;</span><br><span class="line">    &lt;/div&gt;</span><br><span class="line">    &lt;div class=<span class="string">&quot;app2&quot;</span>&gt;</span><br><span class="line">        Vue.js</span><br><span class="line">    &lt;/div&gt;</span><br></pre></td></tr></tbody></table></figure>
<blockquote>
<p>CSS&#x90E8;&#x5206;</p>
</blockquote>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">&lt;style&gt;</span><br><span class="line">       .box{</span><br><span class="line">           width: 300px;</span><br><span class="line">           margin: 50px auto;</span><br><span class="line">       }</span><br><span class="line">       .app1 {</span><br><span class="line">           width: 200px;</span><br><span class="line">           height: 200px;</span><br><span class="line">       }</span><br><span class="line"></span><br><span class="line">       .app2 {</span><br><span class="line">           width: 200px;</span><br><span class="line">           height: 200px;</span><br><span class="line">           background-color: gainsboro;</span><br><span class="line">           opacity: 8;</span><br><span class="line">           display: none;</span><br><span class="line">           text-align: center;</span><br><span class="line">           position: relative;</span><br><span class="line">           top: 0;</span><br><span class="line">       }</span><br><span class="line">   &lt;/style&gt;</span><br></pre></td></tr></tbody></table></figure>
<h3 id="&#x603B;&#x7ED3;"><a href="#&#x603B;&#x7ED3;" class="headerlink" title="&#x603B;&#x7ED3;"></a>&#x603B;&#x7ED3;</h3><blockquote>
<p>&#x2003;&#x2003;&#x4E00;&#x4E2A;Promise&#x53EF;&#x4EE5;&#x6709;&#x591A;&#x4E2A;then&#x51FD;&#x6570;&#x8854;&#x63A5;&#x5904;&#x7406;&#xFF0C;&#x8FBE;&#x5230;&#x4E00;&#x4E2A;&#x540C;&#x6B65;&#x5904;&#x7406;&#x7684;&#x6548;&#x679C;&#xFF0C;&#x6BCF;&#x6B21;then&#x4E4B;&#x540E;&#xFF0C;&#x4E0B;&#x4E00;&#x4E2A;then&#x63A5;&#x6536;&#x7684;&#x662F;&#x4E0A;&#x4E00;&#x4E2A;then&#x7684;return&#x6570;&#x636E;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;then&#x5219;&#x63A5;&#x6536;&#x7684;&#x662F;&#x6700;&#x521D;&#x7684;promise&#x56DE;&#x8C03;resolve&#x653E;&#x884C;&#x7684;&#x6570;&#x636E;&#x3002;</p>
</blockquote>
<script>
        document.querySelectorAll('.github-emoji')
          .forEach(el => {
            if (!el.dataset.src) { return; }
            const img = document.createElement('img');
            img.style = 'display:none !important;';
            img.src = el.dataset.src;
            img.addEventListener('error', () => {
              img.remove();
              el.style.color = 'inherit';
              el.style.backgroundImage = 'none';
              el.style.background = 'none';
            });
            img.addEventListener('load', () => {
              img.remove();
            });
            document.body.appendChild(img);
          });
      </script>
            <div class="post-copyright">
    <div class="content">
        <p>最后更新： 2018年12月30日 08:54</p>
        <p>原始链接： <a class="post-url" href="/8640.html" title="Promise探析">https://bigbigdreamer.github.io/8640.html</a></p>
        <footer>
            <a href="https://bigbigdreamer.github.io">
                <img src="/images/logo.jpg" alt="">
                
            </a>
        </footer>
    </div>
</div>

      
        
            
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;">赏</a>
</div>

<div id="reward" class="post-modal reward-lay">
    <a class="close" href="javascript:;" id="reward-close">×</a>
    <span class="reward-title">
        <i class="icon icon-quote-left"></i>
        请我吃糖~
        <i class="icon icon-quote-right"></i>
    </span>
    <div class="reward-content">
        
        <div class="reward-code">
            <img id="rewardCode" src="/images/wechat_code.jpg" alt="打赏二维码">
        </div>
        <div class="reward-select">
            
            <label class="reward-select-item checked" data-id="wechat" data-wechat="/images/wechat_code.jpg">
                <img class="reward-select-item-wechat" src="/images/wechat.png" alt="微信">
            </label>
            
            
            <label class="reward-select-item" data-id="alipay" data-alipay="/images/alipay_code.jpg">
                <img class="reward-select-item-alipay" src="/images/alipay.png" alt="支付宝">
            </label>
            
        </div>
    </div>
</div>


        
    </div>
    <footer class="article-footer">
        
        
<div class="post-share">
    <a href="javascript:;" id="share-sub" class="post-share-fab">
        <i class="fa fa-share-alt"></i>
    </a>
    <div class="post-share-list" id="share-list">
        <ul class="share-icons">
          <li>
            <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=https://bigbigdreamer.github.io/8640.html&title=《Promise探析》 — null&pic=images/JS.jpg" data-title="微博">
              <i class="fa fa-weibo"></i>
            </a>
          </li>
          <li>
            <a class="weixin share-sns" id="wxFab" href="javascript:;" data-title="微信">
              <i class="fa fa-weixin"></i>
            </a>
          </li>
          <li>
            <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://bigbigdreamer.github.io/8640.html&title=《Promise探析》 — null&source=" data-title="QQ">
              <i class="fa fa-qq"></i>
            </a>
          </li>
          <li>
            <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://bigbigdreamer.github.io/8640.html" data-title="Facebook">
              <i class="fa fa-facebook"></i>
            </a>
          </li>
          <li>
            <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《Promise探析》 — null&url=https://bigbigdreamer.github.io/8640.html&via=https://bigbigdreamer.github.io" data-title="Twitter">
              <i class="fa fa-twitter"></i>
            </a>
          </li>
          <li>
            <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=https://bigbigdreamer.github.io/8640.html" data-title="Google+">
              <i class="fa fa-google-plus"></i>
            </a>
          </li>
        </ul>
     </div>
</div>
<div class="post-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;" id="wxShare-close">×</a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=https://bigbigdreamer.github.io/8640.html" alt="微信分享二维码">
</div>

<div class="mask"></div>

        
        <ul class="article-footer-menu">
            
            
  <li class="article-footer-tags">
    <i class="fa fa-tags"></i>
      
    <a href="/tags/Promise/" class="color3">Promise</a>
      
    <a href="/tags/DOM/" class="color4">DOM</a>
      
    <a href="/tags/ES6/" class="color4">ES6</a>
      
  </li>

        </ul>
        
    </footer>
  </div>
</article>


    <aside class="post-toc-pos post-toc-top" id="post-toc">
        <nav class="post-toc-wrap">
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#前言"><span class="post-toc-text">前言</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#你还在这样写？"><span class="post-toc-text">你还在这样写？</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#DOM原生事件"><span class="post-toc-text">DOM原生事件</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#jQuery写法"><span class="post-toc-text">jQuery写法</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#这样做才爽"><span class="post-toc-text">这样做才爽</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Demo"><span class="post-toc-text">Demo</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#总结"><span class="post-toc-text">总结</span></a></li></ol></li></ol>
        </nav>
    </aside>
    

<nav id="article-nav">
  
    <a href="/bac.html" id="article-nav-newer" class="article-nav-link-wrap">

      <span class="article-nav-title">
        <i class="fa fa-hand-o-left" aria-hidden="true"></i>
        
          vue-router
        
      </span>
    </a>
  
  
    <a href="/7369.html" id="article-nav-older" class="article-nav-link-wrap">
      <span class="article-nav-title">vue @cli3.0的配置</span>
      <i class="fa fa-hand-o-right" aria-hidden="true"></i>
    </a>
  
</nav>



    
        <div id="SOHUCS" sid="Promise"></div>
<script type="text/javascript">
    (function(){
        var appid = 'cytVQxp6s';
        var conf = 'prod_8686c5c96a3bc67353ba410e4bcb37a9';
        var width = window.innerWidth || document.documentElement.clientWidth;
        if (width < 960) {
            window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>'); } else { var loadJs=function(d,a){var c=document.getElementsByTagName("head")[0]||document.head||document.documentElement;var b=document.createElement("script");b.setAttribute("type","text/javascript");b.setAttribute("charset","UTF-8");b.setAttribute("src",d);if(typeof a==="function"){if(window.attachEvent){b.onreadystatechange=function(){var e=b.readyState;if(e==="loaded"||e==="complete"){b.onreadystatechange=null;a()}}}else{b.onload=a}}c.appendChild(b)};loadJs("https://changyan.sohu.com/upload/changyan.js",function(){window.changyan.api.config({appid:appid,conf:conf})}); } })(); </script>
    
</section>
        
      </div>
      <footer id="footer">
  <div class="outer">
    <div id="footer-info" class="inner">
      
<p>
    <span id="busuanzi_container_site_uv" style="display:none">
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style="display:none">
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


      <p>
        Powered by  <a href="http://hexo.io/" target="_blank">Hexo</a>
        Theme <a href="//github.com/wongminho/hexo-theme-miho" target="_blank">MiHo</a>
      &copy; 2019 <br>
      </p>
    </div>
  </div>
</footer>
    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script>
  var mihoConfig = {
      root: "https://bigbigdreamer.github.io",
      animate: true,
      isHome: false,
      share: true,
      reward: 1
  }
</script>
<div class="sidebar">
    <div id="sidebar-search" title="Search">
        <i class="fa fa-search"></i>
    </div>
    <div id="sidebar-category" title="Categories">
        <i class="fa fa-book"></i>
    </div>
    <div id="sidebar-tag" title="Tags">
        <i class="fa fa-tags"></i>
    </div>
    <div id="sidebar-top">
        <span class="sidebar-top-icon"><i class="fa fa-angle-up"></i></span>
    </div>
</div>
<div class="sidebar-menu-box" id="sidebar-menu-box">
    <div class="sidebar-menu-box-container">
        <div id="sidebar-menu-box-categories">
            <a class="category-link" href="/categories/CSS/">CSS</a><a class="category-link" href="/categories/ES6/">ES6</a><a class="category-link" href="/categories/Linux/">Linux</a><a class="category-link" href="/categories/Node/">Node</a><a class="category-link" href="/categories/Vue/">Vue</a><a class="category-link" href="/categories/Vue-Router/">Vue-Router</a><a class="category-link" href="/categories/ajax/">ajax</a><a class="category-link" href="/categories/前端接口调试/">前端接口调试</a><a class="category-link" href="/categories/杂货/">杂货</a><a class="category-link" href="/categories/经验/">经验</a><a class="category-link" href="/categories/设计模式/">设计模式</a>
        </div>
        <div id="sidebar-menu-box-tags">
            <a href="/tags/Async/" style="font-size: 10px;">Async</a> <a href="/tags/Babel-7-0/" style="font-size: 10px;">Babel 7.0</a> <a href="/tags/CSS/" style="font-size: 10px;">CSS</a> <a href="/tags/CSS3/" style="font-size: 10px;">CSS3</a> <a href="/tags/CSS样式/" style="font-size: 10px;">CSS样式</a> <a href="/tags/Collapse/" style="font-size: 10px;">Collapse</a> <a href="/tags/DMZ/" style="font-size: 10px;">DMZ</a> <a href="/tags/DOM/" style="font-size: 10px;">DOM</a> <a href="/tags/ES6/" style="font-size: 17.5px;">ES6</a> <a href="/tags/EXT/" style="font-size: 10px;">EXT</a> <a href="/tags/FAT/" style="font-size: 10px;">FAT</a> <a href="/tags/Function/" style="font-size: 10px;">Function</a> <a href="/tags/HTML5/" style="font-size: 10px;">HTML5</a> <a href="/tags/Hexo/" style="font-size: 10px;">Hexo</a> <a href="/tags/JS/" style="font-size: 10px;">JS</a> <a href="/tags/JS模块化/" style="font-size: 10px;">JS模块化</a> <a href="/tags/JavaScript/" style="font-size: 10px;">JavaScript</a> <a href="/tags/Less/" style="font-size: 10px;">Less</a> <a href="/tags/Linux/" style="font-size: 10px;">Linux</a> <a href="/tags/MarkDown/" style="font-size: 10px;">MarkDown</a> <a href="/tags/Modal/" style="font-size: 10px;">Modal</a> <a href="/tags/Node/" style="font-size: 10px;">Node</a> <a href="/tags/Promise/" style="font-size: 12.5px;">Promise</a> <a href="/tags/Render/" style="font-size: 10px;">Render</a> <a href="/tags/Sync/" style="font-size: 10px;">Sync</a> <a href="/tags/Template/" style="font-size: 10px;">Template</a> <a href="/tags/Vue/" style="font-size: 20px;">Vue</a> <a href="/tags/WebStorm/" style="font-size: 10px;">WebStorm</a> <a href="/tags/ajax/" style="font-size: 10px;">ajax</a> <a href="/tags/axios/" style="font-size: 10px;">axios</a> <a href="/tags/bat文件/" style="font-size: 10px;">bat文件</a> <a href="/tags/dos/" style="font-size: 10px;">dos</a> <a href="/tags/es6/" style="font-size: 10px;">es6</a> <a href="/tags/exports/" style="font-size: 10px;">exports</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/github/" style="font-size: 10px;">github</a> <a href="/tags/iview/" style="font-size: 15px;">iview</a> <a href="/tags/module-exports/" style="font-size: 10px;">module.exports</a> <a href="/tags/newTarget/" style="font-size: 10px;">newTarget</a> <a href="/tags/newYear/" style="font-size: 10px;">newYear</a> <a href="/tags/nginx/" style="font-size: 10px;">nginx</a> <a href="/tags/node/" style="font-size: 10px;">node</a> <a href="/tags/postman/" style="font-size: 10px;">postman</a> <a href="/tags/queue/" style="font-size: 10px;">queue</a> <a href="/tags/scope/" style="font-size: 10px;">scope</a> <a href="/tags/scroll/" style="font-size: 10px;">scroll</a> <a href="/tags/vue/" style="font-size: 15px;">vue</a> <a href="/tags/vue-cli3-0/" style="font-size: 10px;">vue @cli3.0</a> <a href="/tags/vue-cli3-0/" style="font-size: 10px;">vue-cli3.0</a> <a href="/tags/vue-router/" style="font-size: 10px;">vue-router</a> <a href="/tags/webpack/" style="font-size: 10px;">webpack</a> <a href="/tags/一曲相思/" style="font-size: 10px;">一曲相思</a> <a href="/tags/优化体验/" style="font-size: 10px;">优化体验</a> <a href="/tags/单例模式/" style="font-size: 10px;">单例模式</a> <a href="/tags/双大括号表达式/" style="font-size: 10px;">双大括号表达式</a> <a href="/tags/域名/" style="font-size: 10px;">域名</a> <a href="/tags/富文本编辑器/" style="font-size: 10px;">富文本编辑器</a> <a href="/tags/封装/" style="font-size: 10px;">封装</a> <a href="/tags/开发环境/" style="font-size: 10px;">开发环境</a> <a href="/tags/心情/" style="font-size: 10px;">心情</a> <a href="/tags/心灵驿站/" style="font-size: 10px;">心灵驿站</a> <a href="/tags/情感/" style="font-size: 10px;">情感</a> <a href="/tags/搜狐畅言/" style="font-size: 10px;">搜狐畅言</a> <a href="/tags/数据结构/" style="font-size: 10px;">数据结构</a> <a href="/tags/日常修仙/" style="font-size: 10px;">日常修仙</a> <a href="/tags/服务器数据Mock/" style="font-size: 10px;">服务器数据Mock</a> <a href="/tags/杂货/" style="font-size: 10px;">杂货</a> <a href="/tags/柯里化/" style="font-size: 10px;">柯里化</a> <a href="/tags/气泡提示/" style="font-size: 10px;">气泡提示</a> <a href="/tags/生产环境/" style="font-size: 10px;">生产环境</a> <a href="/tags/简单工厂模式/" style="font-size: 10px;">简单工厂模式</a> <a href="/tags/腾讯云/" style="font-size: 10px;">腾讯云</a> <a href="/tags/设计模式/" style="font-size: 12.5px;">设计模式</a> <a href="/tags/调试/" style="font-size: 10px;">调试</a> <a href="/tags/跨域/" style="font-size: 10px;">跨域</a>
        </div>
    </div>
    <a href="javascript:;" class="sidebar-menu-box-close">&times;</a>
</div>
<div class="mobile-header-menu-nav" id="mobile-header-menu-nav">
    <div class="mobile-header-menu-container">
        <span class="title">Menus</span>
        <ul class="mobile-header-menu-navbar">
            
            <li>
                <a href="/">
                    <i class="fa fa-home"></i><span>Home</span>
                </a>
            </li>
            
            <li>
                <a href="/archives">
                    <i class="fa fa-archive"></i><span>Archives</span>
                </a>
            </li>
            
            <li>
                <a href="/about">
                    <i class="fa fa-user"></i><span>About</span>
                </a>
            </li>
            
        </ul>
    </div>
    <div class="mobile-header-tag-container">
        <span class="title">Tags</span>
        <div id="mobile-header-container-tags">
            <a href="/tags/Async/" style="font-size: 10px;">Async</a> <a href="/tags/Babel-7-0/" style="font-size: 10px;">Babel 7.0</a> <a href="/tags/CSS/" style="font-size: 10px;">CSS</a> <a href="/tags/CSS3/" style="font-size: 10px;">CSS3</a> <a href="/tags/CSS样式/" style="font-size: 10px;">CSS样式</a> <a href="/tags/Collapse/" style="font-size: 10px;">Collapse</a> <a href="/tags/DMZ/" style="font-size: 10px;">DMZ</a> <a href="/tags/DOM/" style="font-size: 10px;">DOM</a> <a href="/tags/ES6/" style="font-size: 17.5px;">ES6</a> <a href="/tags/EXT/" style="font-size: 10px;">EXT</a> <a href="/tags/FAT/" style="font-size: 10px;">FAT</a> <a href="/tags/Function/" style="font-size: 10px;">Function</a> <a href="/tags/HTML5/" style="font-size: 10px;">HTML5</a> <a href="/tags/Hexo/" style="font-size: 10px;">Hexo</a> <a href="/tags/JS/" style="font-size: 10px;">JS</a> <a href="/tags/JS模块化/" style="font-size: 10px;">JS模块化</a> <a href="/tags/JavaScript/" style="font-size: 10px;">JavaScript</a> <a href="/tags/Less/" style="font-size: 10px;">Less</a> <a href="/tags/Linux/" style="font-size: 10px;">Linux</a> <a href="/tags/MarkDown/" style="font-size: 10px;">MarkDown</a> <a href="/tags/Modal/" style="font-size: 10px;">Modal</a> <a href="/tags/Node/" style="font-size: 10px;">Node</a> <a href="/tags/Promise/" style="font-size: 12.5px;">Promise</a> <a href="/tags/Render/" style="font-size: 10px;">Render</a> <a href="/tags/Sync/" style="font-size: 10px;">Sync</a> <a href="/tags/Template/" style="font-size: 10px;">Template</a> <a href="/tags/Vue/" style="font-size: 20px;">Vue</a> <a href="/tags/WebStorm/" style="font-size: 10px;">WebStorm</a> <a href="/tags/ajax/" style="font-size: 10px;">ajax</a> <a href="/tags/axios/" style="font-size: 10px;">axios</a> <a href="/tags/bat文件/" style="font-size: 10px;">bat文件</a> <a href="/tags/dos/" style="font-size: 10px;">dos</a> <a href="/tags/es6/" style="font-size: 10px;">es6</a> <a href="/tags/exports/" style="font-size: 10px;">exports</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/github/" style="font-size: 10px;">github</a> <a href="/tags/iview/" style="font-size: 15px;">iview</a> <a href="/tags/module-exports/" style="font-size: 10px;">module.exports</a> <a href="/tags/newTarget/" style="font-size: 10px;">newTarget</a> <a href="/tags/newYear/" style="font-size: 10px;">newYear</a> <a href="/tags/nginx/" style="font-size: 10px;">nginx</a> <a href="/tags/node/" style="font-size: 10px;">node</a> <a href="/tags/postman/" style="font-size: 10px;">postman</a> <a href="/tags/queue/" style="font-size: 10px;">queue</a> <a href="/tags/scope/" style="font-size: 10px;">scope</a> <a href="/tags/scroll/" style="font-size: 10px;">scroll</a> <a href="/tags/vue/" style="font-size: 15px;">vue</a> <a href="/tags/vue-cli3-0/" style="font-size: 10px;">vue @cli3.0</a> <a href="/tags/vue-cli3-0/" style="font-size: 10px;">vue-cli3.0</a> <a href="/tags/vue-router/" style="font-size: 10px;">vue-router</a> <a href="/tags/webpack/" style="font-size: 10px;">webpack</a> <a href="/tags/一曲相思/" style="font-size: 10px;">一曲相思</a> <a href="/tags/优化体验/" style="font-size: 10px;">优化体验</a> <a href="/tags/单例模式/" style="font-size: 10px;">单例模式</a> <a href="/tags/双大括号表达式/" style="font-size: 10px;">双大括号表达式</a> <a href="/tags/域名/" style="font-size: 10px;">域名</a> <a href="/tags/富文本编辑器/" style="font-size: 10px;">富文本编辑器</a> <a href="/tags/封装/" style="font-size: 10px;">封装</a> <a href="/tags/开发环境/" style="font-size: 10px;">开发环境</a> <a href="/tags/心情/" style="font-size: 10px;">心情</a> <a href="/tags/心灵驿站/" style="font-size: 10px;">心灵驿站</a> <a href="/tags/情感/" style="font-size: 10px;">情感</a> <a href="/tags/搜狐畅言/" style="font-size: 10px;">搜狐畅言</a> <a href="/tags/数据结构/" style="font-size: 10px;">数据结构</a> <a href="/tags/日常修仙/" style="font-size: 10px;">日常修仙</a> <a href="/tags/服务器数据Mock/" style="font-size: 10px;">服务器数据Mock</a> <a href="/tags/杂货/" style="font-size: 10px;">杂货</a> <a href="/tags/柯里化/" style="font-size: 10px;">柯里化</a> <a href="/tags/气泡提示/" style="font-size: 10px;">气泡提示</a> <a href="/tags/生产环境/" style="font-size: 10px;">生产环境</a> <a href="/tags/简单工厂模式/" style="font-size: 10px;">简单工厂模式</a> <a href="/tags/腾讯云/" style="font-size: 10px;">腾讯云</a> <a href="/tags/设计模式/" style="font-size: 12.5px;">设计模式</a> <a href="/tags/调试/" style="font-size: 10px;">调试</a> <a href="/tags/跨域/" style="font-size: 10px;">跨域</a>
        </div>
    </div>
</div>
<div class="search-wrap">
    <span class="search-close">&times;</span>
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
            <i class="icon icon-lg icon-chevron-left"></i>
        </a>
        <input class="search-field" placeholder="Search..." id="keywords">
        <a id="search-submit" href="javascript:;">
            <i class="fa fa-search"></i>
        </a>
    <div class="search-container" id="search-container">
        <ul class="search-result" id="search-result">
        </ul>
    </div>
</div>

<div id="search-tpl">
    <li class="search-result-item">
        <a href="{url}" class="search-item-li">
            <span class="search-item-li-title" title="{title}">{title}</span>
        </a>
    </li>
</div>
<script src="/js/search.js"></script>
<script src="/js/main.js"></script>


  <script src="//cdn.bootcss.com/particles.js/2.0.0/particles.min.js"></script>
  <div id="particles"></div>
  <script src="/js/particles.js"></script>







  <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  <script src="//cdn.bootcss.com/scrollReveal.js/3.0.5/scrollreveal.js"></script>
  <script src="/js/animate.js"></script>


  <script src="/js/pop-img.js"></script>
  <script>
     $(".article-entry p img").popImg();
  </script>

  </div>
</body>
</html>